<template>
  <div>
    <el-dialog title="查看单位信息" align="center" :visible="dialogVisible" @close="close" width="60%">
      <div style="padding: 20px;background-color: white;">
        <div>
          <el-row class="erow">
            <el-col :span="24">
              <el-upload
                class="eluploadwrapper"
                :action="uploadUrl"
                :on-success="uploadSuccess"
                :before-upload="beforeUpload"
                drag
                multiple
              >
                <i class="el-icon-upload"></i>
                <div class="el-upload__text">
                  将文件拖到此处，或
                  <em>点击上传</em>
                </div>
              </el-upload>
            </el-col>
            <el-col :span="24">
              <el-table :data="tableData" style="width: 100%" v-show="this.tableData.length != 0">
                <el-table-column label="导入结果">
                  <el-table-column prop="name" label="姓名" show-overflow-tooltip></el-table-column>
                  <el-table-column prop="name" label="姓名" show-overflow-tooltip></el-table-column>
                </el-table-column>
              </el-table>
              <el-table :data="tableData" style="width: 100%" v-show="this.tableData.length == 0">
                <el-table-column label="导入结果"></el-table-column>
              </el-table>
            </el-col>
          </el-row>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { axios } from "@/api/axios";
export default {
  props: {
    dialogVisible: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      uploadUrl: "",
      tableData: [
        // {
        //   date: "2016-05-03",
        //   name: "王小虎",
        //   province: "上海",
        //   city: "普陀区",
        //   address: "上海市普陀区金沙江路 1518 弄",
        //   zip: 200333
        // }
      ]
    };
  },
  created() {
    this.uploadUrl = this.VUE_APP_BASE_API + "/common/webupload.shtml";
  },
  methods: {
    close() {
      console.log(this.tableData.length);
      this.$emit("update:dialogVisible", false);
    },
    beforeUpload() {
      window.loading = this.$loading("正在上传...");
    },
    uploadSuccess(response, file, fileList) {
      let url = response.url;
      window.loading.close();
    //   this.$message("导入成功");
      this.import(url);
    },
    import(authorization) {
      if (authorization) {
        console.log(authorization);
      }

      axios("/admin/linkman/import.do", "post", {
        dir: authorization
      })
        .then(data => {
             this.$message({
            showClose: true,
            message: data.errorMsg,
            type: "warning"
          });
        //   console.log(data);
          // this.empty();
          // this.$emit("finish", 1);
          // this.$emit("update:dialogVisible", false);
        })
        .catch(function(err) {
         
        });
    }
  }
};
</script>
<style >
</style>